
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2
 * @Author : WangRuoyu 
 * @Date : 2023/5/11 11:22
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int const N = 1010;
int n;

struct pp {
    int x, y;
} nums[N];

static bool cmp(pp a, pp b) {
    return a.y == b.y ? a.x < b.x : b.y < a.y;
}

int main() {
    cin >> n;
    for (int i = 0; i < N; ++i) {
        nums[i].x = i;
        nums[i].y = 0;
    }
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        nums[x].y++;
    }
    sort(nums, nums + N, cmp);
    for (int i = 0; i < N; ++i) {
        if (!nums[i].y) {
            break;
        }
        cout << nums[i].x << " " << nums[i].y << endl;
    }
    return 0;
}
